<?php


namespace frontend\models;
use Yii;
use yii\db\ActiveRecord;

class Collect  extends ActiveRecord
{
    public $goods_id;
    public static function tableName()
    {
        return '{{collect}}';
    }

//    public  function getCollects(){
//        // 第一个参数为要关联的子表模型类名，
//        // 第二个参数指定 通过子表的user_id，关联主表的usesr_id字段
//        // 这里写清楚点大概意思就是User.user_id => Order.user_id
//        return $this->hasMany(User::className(), ['user_id' => 'user_id']);
//    }


    public static function getcollect($userid){
        $goods_id=self::find()
            ->where(['user_id' => $userid])
            ->asArray()
            ->all();
        //var_dump($goods_id);die;
      return  self::getgoodsidArray($goods_id);

    }
    public static function   getgoodsidArray($goods_id){
        $array=[];
            foreach ($goods_id as $key =>$value){
                array_unshift($array,$value['goods_id']);
            }
           return $array;
    }
}